package com.example.demo.service.impl;

import com.example.demo.entity.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.UserService;
import com.example.demo.utils.MD5Utils;

public class UserServiceImpl implements UserService {
    @Override
    private UserMapper userMapper;

    @Override
    public User login(String username, String pwd) {
        pwd = MD5Utils.md5(pwd);
        User user = userMapper.login(username);
        if (user != null) {
            if (pwd.equals(user.getPwd())) {
                return user;
            }
        }
        return null;
    }

    @Override
    public Boolean add(String username, String pwd, Integer age) {
        String aa = MD5Utils.md5(pwd);
        User user = new User();
        user.setUsername(username);
        user.setPwd(pwd);
        user.setAge(age);
        int b = userMapper.add(user);
        if (b > 0) return true;
        return false;
    }
}
